package libs.yzx.zaza.acts;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

public class CustomerView extends View {

    public CustomerView(Context context) {
        super(context);
    }
    public CustomerView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    public CustomerView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int w_result , h_result;

        /* 判断view的宽的设置,如果是wrap_content , 就让宽度是0(也可以指定100,200啥的具体的数值),
               如果是具体的px值(比如100px)或者match_parent , 就使用这个值 */
        {
            int w_mode = MeasureSpec.getMode(widthMeasureSpec);
            int w_size = MeasureSpec.getSize(widthMeasureSpec);
            w_result = (w_mode == MeasureSpec.EXACTLY) ? w_size : 0;
        }

        /* 判断view的高的设置,如果是wrap_content , 就让高度是0(也可以指定100,200啥的具体的数值) ,
           如果是具体的px值(比如100px)或者match_parent , 就使用这个值 */
        {
            int h_mode = MeasureSpec.getMode(heightMeasureSpec);
            int h_size = MeasureSpec.getSize(heightMeasureSpec);
            h_result = (h_mode == MeasureSpec.EXACTLY) ? h_size : 0;
        }

        setMeasuredDimension(w_result,h_result);
    }

}
